var api = require('../../util/api.js');
Page({

  data: {

  },

  onLoad: function (options) {
    api.chain({
      mode: 'VIEW'
    });
    this.setData({
      page: api.page(10),
      dataList: [],
      params: {
        subType: 4
      }
    });
    this.onReachBottom();
  },
  onPullDownRefresh() {
    this.setData({
      page: api.page(10),
      dataList: []
    });
    this.loadList();
  },
  onReachBottom() {
    this.loadList();
  },
  loadList() {
    var _this = this;
    var params = _this.data.params;
    var page = _this.data.page;
    api.get(api.url.examineList, params, page).then(res => {
      page.setTotal(res.total);
      if (res.rows.length == 0) {
        this.setData({
          hasData: false
        })
      } else {
        _this.setData({
          hasData: true,
          dataList: _this.data.dataList.concat(res.rows)
        });
      }
    })
  },
  scoreAnalyze: function (e) {
    api.chain({
      examineId: e.currentTarget.dataset.id,
      examineName: e.currentTarget.dataset.name
    });
    wx.navigateTo({
      url: `../examine_analyze/home`
    })
  }
})